let env = null;
let baseApi = {};

// #ifdef H5
env = process.env.NODE_ENV;
baseApi = {
  development: {
    base: "https://test.qmgdj.com",
    api: "https://test.qmgdj.com/api",
    file: "https://test.qmgdj.com/static/applet_images",
    img: "https://test.qmgdj.com/static/applet_images",
    apiImg: "https://test.qmgdj.com", // "https://qingmangguodaojia-test.oss-cn-hangzhou.aliyuncs.com/",
    upload: "https://test.qmgdj.com/api/utils/upload",
  },
  production: {
    base: "https://test.qmgdj.com",
    api: "https://test.qmgdj.com/api",
    file: "https://test.qmgdj.com/static/applet_images",
    img: "https://test.qmgdj.com/static/applet_images",
    apiImg: "https://test.qmgdj.com", // "https://qingmangguodaojia-test.oss-cn-hangzhou.aliyuncs.com/",
    upload: "https://test.qmgdj.com/api/utils/upload",
  },
};
// #endif

// #ifdef MP-WEIXIN
const accountInfo = uni.getAccountInfoSync();
env = accountInfo.miniProgram.envVersion;
baseApi = {
  // 开发版
  develop: {
    base: "https://test.qmgdj.com",
    api: "https://test.qmgdj.com/api",
    file: "https://test.qmgdj.com/static/applet_images/",
    // img: "https://test.qmgdj.com/static/applet_images", // 拼接服务器上的图片域名
    img: "https://qingmangguodaojia-test.oss-cn-hangzhou.aliyuncs.com/static/applet_images",
    // apiImg: "https://test.qmgdj.com", // "https://qingmangguodaojia-test.oss-cn-hangzhou.aliyuncs.com/", // 接口返回图片通常是全路径,为了防止以后改成半路径,预留域名字段
    apiImg: "https://qingmangguodaojia-test.oss-cn-hangzhou.aliyuncs.com",
    upload: "https://test.qmgdj.com/api/utils/upload",
  },
  // 体验版 https://shop-uat.qingmangguojianzhu.com
  // https://test.qmgdj.com/static/applet_images/login_top_color.png
  trial: {
    base: "https://test.qmgdj.com",
    api: "https://test.qmgdj.com/api",
    file: "https://test.qmgdj.com/static/applet_images/",
    // img: "https://shop.qmgdj.com/static/applet_images",
    img: "https://qingmangguodaojia-test.oss-cn-hangzhou.aliyuncs.com/static/applet_images",
    // apiImg: "https://shop.qmgdj.com", // "https://qingmangguodaojia-test.oss-cn-hangzhou.aliyuncs.com",
    apiImg: "https://qingmangguodaojia-test.oss-cn-hangzhou.aliyuncs.com",
    upload: "https://test.qmgdj.com/api/utils/upload",
  },
  // 正式版
  release: {
    base: "https://shop.qmgdj.com",
    api: "https://shop.qmgdj.com/api",
    file: "https://shop.qmgdj.com/static/applet_images/",
    // img: "https://shop.qmgdj.com/static/applet_images",
    img: "https://qingmangguodaojia-test.oss-cn-hangzhou.aliyuncs.com/static/applet_images",
    // apiImg: "https://shop.qmgdj.com", // "https://qingmangguodaojia-test.oss-cn-hangzhou.aliyuncs.com",
    apiImg: "https://qingmangguodaojia-test.oss-cn-hangzhou.aliyuncs.com",
    upload: "https://shop.qmgdj.com/api/utils/upload",
  },
};
// #endif
console.log("环境###", env);
/** 开发环境 */
const isDev = ["development", "develop"].includes(env);
/** 体验版(小程序) */
const isTrial = ["trial"].includes(env);
/** 生产环境 */
const isPro = ["production", "release"].includes(env);
const baseUrl = baseApi[env].base;
const apiUrl = baseApi[env].api;
const fileUrl = baseApi[env].file;
/** 拼接服务器上的图片域名 */
const imgUrl = baseApi[env].img;
/** 接口返回图片通常是全路径,为了防止以后改成半路径,预留域名字段 */
const apiImgUrl = baseApi[env].apiImg;
const uploadUrl = baseApi[env].upload;
const webviewUrl = baseApi[env].base;
export {
  env,
  baseApi,
  baseUrl,
  fileUrl,
  apiUrl,
  imgUrl,
  uploadUrl,
  webviewUrl,
  isDev,
  isTrial,
  isPro,
  apiImgUrl,
};
